/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VistaCuenta.java
 *
 * Created on Dec 21, 2011, 2:06:50 PM
 */

package INTERFAZ;
import CONTROLES.ControlCliente;
import CONTROLES.ControlCuenta;
import CONTROLES.ControlSucursal;
import MODELOS.Cliente;
import MODELOS.Cuenta;
import MODELOS.Pago;
import MODELOS.PlanInversion;
import Reportes.Reporte;
import UTILITARIOS.Fecha;
import UTILITARIOS.Herramienta;
import UTILITARIOS.MiModelo;
import UTILITARIOS.StringToDate;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
/**
 *
 * @author VICENTE
 */
public class VistaCuenta extends javax.swing.JDialog {

    /** Creates new form VistaCuenta */
    public VistaCuenta(javax.swing.JFrame parent, boolean modal, Cuenta c) {
        super(parent, modal);
        this.cuenta = c;
        this.cliente = this.cuenta.getCliente();
        this.planI = this.cuenta.getPlan();
        initComponents();
        cambiarPropiedades();
        addEventos(parent);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        nombre = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        imprimirC = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaPagos = new javax.swing.JTable();
        pagar = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        verRecibo = new javax.swing.JButton();
        cerrarCuenta = new javax.swing.JButton();
        checkCerrar = new javax.swing.JCheckBox();
        jButton2 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        salir = new javax.swing.JButton();
        jLabel29 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2), "DATOS DE CUENTA", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jPanel1.setName("jPanel1"); // NOI18N

        jPanel2.setBackground(java.awt.Color.white);
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del Cliente"));
        jPanel2.setName("jPanel2"); // NOI18N

        nombre.setText("NOMBRE:");
        nombre.setName("nombre"); // NOI18N

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("jLabel2");
        jLabel2.setName("nomCliente"); // NOI18N

        jLabel3.setText("C.I.:");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("jLabel4");
        jLabel4.setName("ciCliente"); // NOI18N

        jLabel5.setText("FONO:");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("jLabel6");
        jLabel6.setName("fonoCliente"); // NOI18N

        jLabel7.setText("CEL:");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("jLabel8");
        jLabel8.setFocusCycleRoot(true);
        jLabel8.setName("celCliente"); // NOI18N

        jLabel11.setText("DIRECCION:");
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setBackground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("jLabel12");
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(nombre)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE))
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombre)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS DE LA CUENTA"));
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel14.setText("Nº  CUENTA : ");
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setText("jLabel15");
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setText("SUCURSAL : ");
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setText("nombre sucursal");
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setText("TIPO DE PLAN :");
        jLabel18.setName("jLabel18"); // NOI18N

        jLabel19.setText("jLabel19");
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel20.setText("FECHA INICIO : ");
        jLabel20.setName("jLabel20"); // NOI18N

        jLabel21.setText("jLabel21");
        jLabel21.setName("jLabel21"); // NOI18N

        jLabel22.setText("DURACION :");
        jLabel22.setName("jLabel22"); // NOI18N

        jLabel23.setText("jLabel23");
        jLabel23.setName("jLabel23"); // NOI18N

        jLabel24.setText("PORCENTAJE : ");
        jLabel24.setName("jLabel24"); // NOI18N

        jLabel25.setForeground(new java.awt.Color(255, 102, 102));
        jLabel25.setText("jLabel25");
        jLabel25.setName("jLabel25"); // NOI18N

        jLabel26.setText("MONTO : ");
        jLabel26.setName("jLabel26"); // NOI18N

        jLabel27.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel27.setText("jLabel27");
        jLabel27.setName("jLabel27"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setText("$us");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel10.setText("jLabel10");
        jLabel10.setName("jLabel10"); // NOI18N

        imprimirC.setText("Imprimir Contrato");
        imprimirC.setName("imprimirC"); // NOI18N

        jButton1.setText("Nueva Cuenta");
        jButton1.setName("jButton1"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel20)
                    .addComponent(jLabel16)
                    .addComponent(jLabel24)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(81, 81, 81)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel26)
                            .addComponent(jLabel22)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1))
                            .addComponent(jLabel23)
                            .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)
                        .addGap(27, 27, 27)
                        .addComponent(imprimirC)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap(31, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(imprimirC)
                            .addComponent(jButton1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(jLabel25)
                            .addComponent(jLabel10)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel26)
                            .addComponent(jLabel27)
                            .addComponent(jLabel1))))
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "LISTA DE PAGOS DE INTERESES", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tablaPagos.setName("tablaPagos"); // NOI18N
        jScrollPane1.setViewportView(tablaPagos);

        pagar.setForeground(new java.awt.Color(255, 0, 0));
        pagar.setText("PAGAR INTERESES");
        pagar.setEnabled(false);
        pagar.setName("pagar"); // NOI18N

        jLabel13.setFont(new java.awt.Font("Times New Roman", 0, 11));
        jLabel13.setText("NOTA: El boton solo se habilitara si tiene algun pago disponible =>");
        jLabel13.setName("jLabel13"); // NOI18N

        jLabel28.setFont(new java.awt.Font("Times New Roman", 0, 11));
        jLabel28.setText("Para poder ver los un INTERES PAGADO seleccionelo en la tabla y luego presione el boton =>");
        jLabel28.setName("jLabel28"); // NOI18N

        verRecibo.setText("Ver PAGO");
        verRecibo.setEnabled(false);
        verRecibo.setName("verRecibo"); // NOI18N

        cerrarCuenta.setText("CANCELAR CUENTA");
        cerrarCuenta.setEnabled(false);
        cerrarCuenta.setName("cerrarCuenta"); // NOI18N

        checkCerrar.setBackground(new java.awt.Color(255, 255, 255));
        checkCerrar.setToolTipText("Seleccione para habilitar el boton");
        checkCerrar.setName("checkCerrar"); // NOI18N

        jButton2.setText("Deposito Bancario");
        jButton2.setName("jButton2"); // NOI18N

        jLabel9.setText("<= Cambiar Modo de Pago A");
        jLabel9.setName("jLabel9"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(3, 3, 3)
                        .addComponent(pagar))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 812, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(cerrarCuenta)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(checkCerrar)
                        .addGap(112, 112, 112)
                        .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 451, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(verRecibo, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel9)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(pagar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel28)
                        .addComponent(verRecibo)
                        .addComponent(cerrarCuenta))
                    .addComponent(checkCerrar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jLabel9))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        salir.setText("SALIR");
        salir.setName("salir"); // NOI18N

        jLabel29.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel29.setText("jLabel29");
        jLabel29.setName("jLabel29"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 844, Short.MAX_VALUE)
                    .addComponent(salir, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel29)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(salir)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cambiarPropiedades(){

        Fecha df = new Fecha();
        df.setFecha(cuenta.getFechaApertura());

        jLabel2.setText(cliente.getNombreCliente()+" "+cliente.getApellidosCli());
        jLabel4.setText(Integer.toString(cliente.getCiCliente()));
        jLabel6.setText(Integer.toString(cliente.getTelefono()));
        jLabel8.setText(Integer.toString(cliente.getCelular()));
        jLabel12.setText(cliente.getDireccion());
        jLabel15.setText(Long.toString(cuenta.getNumeroCuenta()));
        jLabel17.setText(cuenta.getSucursal().getNombreSuc());
        jLabel19.setText(planI.getNombrePlan());
        jLabel23.setText(Integer.toString(planI.getDuracion())+ " Meses");
        jLabel21.setText(df.getFechaPrincipal());
        jLabel25.setText(Double.toString(cuenta.getPorcentajeInteres())+ " %");
        jLabel10.setText(" Mensual");
        jLabel27.setText(Herramienta.redondearDoubleString(cuenta.getMonto()));
        jLabel29.setText(cuenta.getEstado());

        modelo_pagos = new MiModelo(new Object [][] {},new String [] {"ID","Nº Pago", "Fecha a Pagar", "Estado", "Monto Sus", "Nº Recibo"}, -1);
        listPagos = cuenta.getPagos();
        Pago pg;
        StringToDate st = new StringToDate();
        if(listPagos.size()>0){
            for(int i=0;i<listPagos.size();i++){
                pg = listPagos.get(i);                
                Object [] auxPago = {
                    pg.getIdPago(),
                    pg.getNumeroPago(),
                    st.dateAstring(pg.getFechaPago()),
                    pg.getEstado(),
                    Herramienta.redondearDoubleString(pg.getMonto()),
                    pg.getIdRecibo()
                };
               
                modelo_pagos.addRow(auxPago);
            }
        }
        tablaPagos.setModel(modelo_pagos);
        tablaPagos.getTableHeader().setReorderingAllowed(false) ;//para impedir que se muevan las columnas de la tabla

        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();
        tcr.setHorizontalAlignment(SwingConstants.RIGHT);

        DefaultTableCellRenderer tcrc = new DefaultTableCellRenderer();
        tcrc.setHorizontalAlignment(SwingConstants.CENTER);

        ColoredTableCellRenderer c = new ColoredTableCellRenderer();

        tablaPagos.getColumnModel().getColumn(0).setCellRenderer(tcr);
        tablaPagos.getColumnModel().getColumn(1).setCellRenderer(tcr);
        tablaPagos.getColumnModel().getColumn(2).setCellRenderer(c);
        tablaPagos.getColumnModel().getColumn(3).setCellRenderer(tcrc);
        tablaPagos.getColumnModel().getColumn(4).setCellRenderer(tcr);
        tablaPagos.getColumnModel().getColumn(5).setCellRenderer(tcr);       
        tablaPagos.getColumnModel().getColumn(0).setMaxWidth(80);
        tablaPagos.getColumnModel().getColumn(1).setMaxWidth(100);
        tablaPagos.getColumnModel().getColumn(5).setMaxWidth(100);

        if(cuenta.getPagosDisponibles().size()>0)
            pagar.setEnabled(true);

        if(cuenta.getEstado().compareTo("ACTIVA")!= 0){
            checkCerrar.setEnabled(false);
        }
        if(cuenta.getModoPago().compareTo("DEPOSITO BANCARIO")== 0){
            jButton2.setVisible(false);
            jLabel9.setVisible(false);

        }

    }
    
    private void addEventos(final javax.swing.JFrame parent){
        final javax.swing.JFrame padre = parent;
        final javax.swing.JDialog yo = this;

        tablaPagos.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent e)
            {
                int filaSelecionada = tablaPagos.getSelectedRow();
                if(listPagos.get(filaSelecionada).getEstado().compareTo("PAGADO") == 0)
                        verRecibo.setEnabled(true);
                else
                        verRecibo.setEnabled(false);
            }
        });
        imprimirC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Reporte rep = new Reporte();
                System.out.println("id de la cuenta.. ."+cuenta.getIdCuenta() );
                rep.ejecutarReporteVacio(cuenta.getIdCuenta());
            }
        });

        jButton2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int res = JOptionPane.showConfirmDialog(null, "Va a Cambiar el metodo de pago de intereses de PAGO DIRECTO a DEPOSITO BANCARIO \n Esta seguro de Hacer esto?", "Advertencia", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                if(res ==0){
                    if(cliente.getCuenta() > 0){
                        if(new ControlCuenta().updateMetodoPago(cuenta.getIdCuenta())== true)
                          JOptionPane.showMessageDialog(null, "Se modifico el metodo de pago de intereses de la cuenta a DEPOSITO BANCARIO", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
                    }else{
                        int res1 = JOptionPane.showConfirmDialog(null, "El cliente no tiene Registrado un numero de cuenta Bancaria\n Si desea Registrar un numero de cuenta Bancaria presione OK?", "Advertencia", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                        if(res1 ==0){
                            dispose();
                            EditarCliente ed = new EditarCliente();
                            Herramienta.centerOnScreen(ed);
                            ed.setIdCliente(cliente.getIdCliente());
                            ControlSucursal cs = new ControlSucursal();
                            String sucursal = cliente.getIdSucursal()+"-"+cs.dameNomSucursal(cliente.getIdSucursal());

                            ed.setSucursal(sucursal);
                            ed.setTxtApellido(cliente.getApellidosCli());
                            ed.setTxtCelular(String.valueOf(cliente.getCelular()));
                            ed.setTxtCi(String.valueOf(cliente.getCiCliente()));
                            ed.setTxtDireccion(cliente.getDireccion());
                            ed.setTxtNit(String.valueOf(cliente.getNit()));
                            ed.setTxtNombre(cliente.getNombreCliente());
                            ed.setTxtProcedencia(cliente.getCiProcedencia());
                            ed.setTxtTelefono(String.valueOf(cliente.getTelefono()));
                            ed.setVisible(true);
                        }
                    }

                }

            }
        });
        pagar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if((listPagos.size()- cuenta.getPagosPagados().size()- cuenta.getPagosDisponibles().size())==0){
                    int res = JOptionPane.showConfirmDialog(null, "Se pagaran los ultimos Intereses pendientes de esta cuenta\n Con lo que se procedera a Cerrar la Cuenta", "Advertencia", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
                    if(res ==0){
                        dispose();
//                        if(cuenta.facturaDisponible()){
//                            GenerarFactura factura = new GenerarFactura(cuenta.getPagosDisponibles());
//                            Herramienta.centerOnScreen(factura);
//                            factura.setVisible(true);
//
//                        }else{
                            GenerarReciboCancelarCuenta nuevoRecibo = new GenerarReciboCancelarCuenta(yo, true, cuenta, "CERRADA", "DIRECTO");
                            Herramienta.centerOnScreen(nuevoRecibo);
                            nuevoRecibo.setVisible(true);
//                        }
                    }
                }else{
                    dispose();
//                    if(cuenta.facturaDisponible()){
//                            GenerarFactura factura = new GenerarFactura(cuenta.getPagosDisponibles());
//                            Herramienta.centerOnScreen(factura);
//                            factura.setVisible(true);
//
//                        }else{
                            GenerarReciboPagoCuenta nuevoRecibo = new GenerarReciboPagoCuenta(yo, true, cuenta, "DIRECTO");
                            Herramienta.centerOnScreen(nuevoRecibo);
                            nuevoRecibo.setVisible(true);
//                    }
                }
            }
        });

        verRecibo.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();
                int idPago = listPagos.get(tablaPagos.getSelectedRow()).getIdRecibo();
                System.out.println("id pago="+idPago);
                VerReciboPagoCuenta recibo = new VerReciboPagoCuenta(yo,true, idPago);
                Herramienta.centerOnScreen(recibo);
                recibo.setVisible(true);
            }
        });
        checkCerrar.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if(checkCerrar.isSelected()== true)
                    cerrarCuenta.setEnabled(true);
                else
                    cerrarCuenta.setEnabled(false);
            }
        });
        cerrarCuenta.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                int res = JOptionPane.showConfirmDialog(null, "ADVERTENCIA: \n Va a cerrar la cuenta prematuramente esta seguro de querer hacer esto?", "Advertencia", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                if(res ==0){
//                    if(new ControlCuenta().cerrarCuenta(cuenta)){
//                        JOptionPane.showMessageDialog(null, "La CUENTA ha sido cerrada Correctamente\n prepare la impresora para imprimir el recibo de CIERRE de CUENTA", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
                        setVisible(false);
                        GenerarReciboCancelarCuenta recibo = new GenerarReciboCancelarCuenta(yo, true, cuenta, "CANCELADA", "DIRECTO");
                        Herramienta.centerOnScreen(recibo);
                        recibo.setVisible(true);
//                    }
                }
            }
        });
        salir.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });

        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();
                FormNewCuenta newCuenta = new FormNewCuenta(parent, cliente);
                Herramienta.centerOnScreen(newCuenta);
                newCuenta.setVisible(true);
            }
        });
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
//        VistaCuenta dialog = new VistaCuenta(new javax.swing.JFrame(), true, new );
//        dialog.setVisible(true);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cerrarCuenta;
    private javax.swing.JCheckBox checkCerrar;
    private javax.swing.JButton imprimirC;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel nombre;
    private javax.swing.JButton pagar;
    private javax.swing.JButton salir;
    private javax.swing.JTable tablaPagos;
    private javax.swing.JButton verRecibo;
    // End of variables declaration//GEN-END:variables

    private MiModelo modelo_pagos;

    private Cuenta cuenta;
    private Cliente cliente;
    private PlanInversion planI;
    ArrayList<Pago> listPagos;
}

class ColoredTableCellRenderer extends DefaultTableCellRenderer
{
    @Override
    public Component getTableCellRendererComponent (JTable table, Object value, boolean selected, boolean focused, int row, int column)
    {
        setEnabled(table == null || table.isEnabled()); // see question above

        Date f = new Fecha().getFechaDate();
        Date v = new Date();
        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        try{
            v = df.parse(String.valueOf(value));        
            }catch (ParseException e){
                            e.printStackTrace();
            }        
        if ((f.getTime()>= v.getTime()) && String.valueOf(table.getValueAt(row, 3)).compareTo("PENDIENTE")== 0)
            setBackground(new java.awt.Color(255, 102, 102));
        else
            setBackground(null);
        setHorizontalAlignment(CENTER);
        super.getTableCellRendererComponent(table, value, selected, focused, row, column);
        return this;
    }
}